#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100 , P = 5;
const int prime[P] = {2, 3, 7, 61, 24251};
ll cnt, pri[N];
ll add(ll a, ll b, ll p){
	return (a += b) >= p ? a - p : a;
}
ll mul(ll a, ll b, ll p)
{
	a %= p, b %= p;
	ll c = (long double) a * b / p;
	c = a * b - c * p;
	return (c + p) % p;
}
ll random(ll p){
	return 1ll * rand() * rand() % p;
}
ll gcd(ll a, ll b){
	return !b ? a : gcd(b, a % b);
}
ll trans(ll x, ll y, ll p){
	return add(mul(x, x, p), y, p);
}
ll fast_pow(ll a, ll b, ll p)
{
	ll res = 1;
	for (; b; b >>= 1, a = mul(a, a, p))
		if (b & 1) res = mul(res, a, p);
	return res;
}
bool Miller_Rabin_check(ll a, ll p)
{
	ll cur = p - 1, tim = 0;
	for (; !(cur & 1); cur >>= 1, tim++);
	ll x = fast_pow(a, cur, p);
	for (int i = 1; i <= tim; i++)
	{
		ll y = mul(x, x, p);
		if (y == 1 && (x != 1) && (x != p - 1)) return 0;
		x = y;
	}
	return x == 1;
}
bool Miller_Rabin(ll x)
{
	for (int i = 0; i < P; i++)
	{
		if (x == prime[i]) return 1;
		if (!Miller_Rabin_check(prime[i], x)) return 0;
	}
	return 1;
}
void Pollard_Rho(ll x)
{
	if (Miller_Rabin(x))
	{
		pri[++cnt] = x;
		return;
	}
	ll x1 = 0, x2 = 0, c = 0, p = 1;
	while (p == 1 || p == x)
	{
		x1 = trans(x1, c, x);
		x2 = trans(trans(x2, c, x), c, x);
		while (x1 == x2)
		{
			c = random(x);
			x1 = x2 = random(x);
			x2 = trans(x2, c, x);
		}
		p = gcd(abs(x1 - x2), x);
	}
	Pollard_Rho(p);
	Pollard_Rho(x / p);
}
ll get_phi(ll x)
{
	srand(time(0));
	if(x == 1) return 1;
	cnt = 0;
	Pollard_Rho(x);
	sort(pri + 1, pri + cnt + 1);
	cnt = unique(pri + 1, pri + cnt + 1) - pri - 1;
	for (int i = 1; i <= cnt; i++)
		x = x / pri[i] * (pri[i] - 1);
	return x;
}
signed main()
{
	ll n ;
	cin >> n;
	cout << get_phi(n) << '\n';
	return 0;
}
